package com.jash.designpack;

import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class Main2Activity extends AppCompatActivity implements View.OnClickListener {

    private CoordinatorLayout coordinator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler);
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            list.add(String.format(Locale.getDefault(), "item %03d", i + 1));
        }
        MyAdapter adapter = new MyAdapter(this, list);
        recyclerView.setAdapter(adapter);
        findViewById(R.id.action_btn).setOnClickListener(this);
        coordinator = (CoordinatorLayout) findViewById(R.id.activity_main2);
    }

    @Override
    public void onClick(View view) {
        Snackbar.make(coordinator, "提示信息", Snackbar.LENGTH_LONG).show();
    }
}
